#include<iostream>
#include<string>
using namespace std;


class Solution {
public:

    string countAndSay(int n)
    {
        if (n == 1)return "1";
        string tmp = countAndSay(n - 1), ret;
        int count = tmp.size();

        for (int left = 0, right = 0; right < count;)
        {
            while (right < count && tmp[right] == tmp[left])
            {
                right++;
            }

            ret += char(right - left + '0');
            ret += (char)tmp[left];


            left = right;
        }
        return ret;

    }

};


int main()
{
    class Solution().countAndSay(4);


    return 0;
}